package com.bitoon.basketdudes.web.jpa;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;

 // @author paco

@Entity
@Table(name = "gashaballitem", schema = "basket")
@NamedQueries({
    @NamedQuery(name = "Gashaballitem.findAll"      , query = "SELECT s FROM Gashaballitem s order by s.gashaballId,s.id"),
    @NamedQuery(name = "Gashaballitem.findById"     , query = "SELECT s FROM Gashaballitem s WHERE s.id = :id"),
    @NamedQuery(name = "Gashaballitem.findByParent" , query = "SELECT s FROM Gashaballitem s WHERE s.gashaballId = :padre order by probability")
})


public class Gashaballitem implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;

    @Basic(optional = false)
    @Column(name = "gashaball_id")
    private int gashaballId;

    @Basic(optional = false)
    @Column(name = "item_type")
    private int itemType;

    @Basic(optional = false)
    @Column(name = "item_id")
    private int itemId;

    @OneToOne
    @JoinColumn(name = "item_id", referencedColumnName = "id",insertable = false, updatable = false)
    private Ropa objeto;

    @Basic(optional = false)
    @Column(name = "probability")
    private int probability;

    public Gashaballitem() {
    }

    public Gashaballitem(Integer id) {
        this.id = id;
    }

    public Gashaballitem(int p_id, int p_gashaballId, int p_itemType, int p_itemId, int p_probability) {
        this.id         = p_id;
        this.gashaballId= p_gashaballId;
        this.itemType   = p_itemType;
        this.itemId     = p_itemId;
        this.probability= p_probability;
    }

    public int  getId()                 {  return id;           }
    public void setId(int v)            {  this.id = v;         }

    public int  getGashaballId()        {  return gashaballId;  }
    public void setGashaballId(int v)   {  this.gashaballId = v;}

    public int  getItemType()           {  return itemType;     }
    public void setItemType(int v)      {  this.itemType = v;   }

    public int  getItemId()             {  return itemId;       }
    public void setItemId(int v)        {  this.itemId = v;     }

    public int  getProbability()        {  return probability;  }
    public void setProbability(int v)   {  this.probability = v;}


    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Gashaball)) {
            return false;
        }
        Gashaballitem other = (Gashaballitem) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bitoon.basketdudes.jpa.Gashaballitem[id=" + id + "]";
    }

    public Ropa getObjeto() {
        return objeto;
    }

    public void setObjeto(Ropa objeto) {
        this.objeto = objeto;
    }

}
